<template>
	<view>
		<view class="head-portrait">
			<view class="title">头像</view>
			<view class="img">
				<!-- <image :src="avatarUrl" mode=""></image> -->
				<image src="../../static/images/user.png" mode=""></image>
			</view>
		</view>
		<view class="username">
			<view class="title">用户名</view>
			<view class="name">{{name!='undefined'?name:''}}</view>
		</view>
		<view class="username" @click="goUpdatePsd">
			<view class="title">修改密码</view>
			<image src="../../static/images/right_1.png" class="right-icon" mode=""></image>
		</view>
		<view class="username" @click="out">
			<view class="title">退出登录</view>
			<image src="../../static/images/right_1.png" class="right-icon" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				avatarUrl:'',
			}
		},
		onShow() {
			if(this.type_==2){
				AlipayJSBridge.call('setTitle', {
				      title: '专注卡券回收服务—卖卡啦'
				    });
			}else{
				uni.setNavigationBarTitle({
					title: "专注卡券回收服务—卖卡啦"
				})
			}
			let _this=this;
			
			
			uni.login({
				provider: 'weixin',
				success: function (res) {
					console.log(res.code);
					// 获取用户信息
					uni.getUserInfo({
						provider: 'weixin',
						success: function (res) {
							console.log('用户昵称为：' + res.userInfo.nickName);
							_this.name = res.userInfo.nickName
							_this.avatarUrl = res.userInfo.avatarUrl
						}
					});
				},
			})
			
			uni.request({
				url: this.url + '/mobile/realData',
				method:'GET',
				header: {
					'content-type': 'application/x-www-form-urlencoded' ,// 默认值
					'token': uni.getStorageSync('token')
				},
				data:{
					
				},
				success: (res) => {
					console.log(res);
					this.rebateMoney = res.data.rebateMoney+''
					if(res.data.realName!=''){
					  _this.name = res.data.realName+''
					}else{
					 _this.name = res.data.name+''
					}
					this.phone = res.data.tel+''
				}
			})
			
		},
		methods: {
			out(){
				uni.clearStorageSync()
				uni.navigateTo({
					url: '../login/login'
				});
			},
			goUpdatePsd(){
				uni.navigateTo({
					url: '../updatePsd/updatePsd'
				});
			}
		}
	}
</script>

<style>
	.title{
		display: inline-block;
		font-size: 34upx;
		line-height: 100upx;
		float: left;
	}
	.head-portrait{
		width: 100%;
		height: 180upx;
		padding: 40upx 20upx;
		box-sizing: border-box;
	}
	.head-portrait .img{
		display: inline-block;
		float: right;
		width: 100upx;
		height: 100upx;
		border-radius: 50%;
	}
	.head-portrait .img image{
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}
	.username{
		position: relative;
		width: 100%;
		height: 100upx;
		padding: 0 20upx;
		box-sizing: border-box;
	}
	.username .name{
		float: right;
		padding-right: 40upx;
		line-height: 100upx;
		color: #707070;
	}
	.username .right-icon{
		width: 40upx;
		height: 50upx;
		position: absolute;
		top: 25upx;
		right: 10upx;
	}
</style>
